Component({
  mixins: [],
  data: {
    step:100,
    enemyData:{},
		animation:'',
		
		// bg:{
		// 	url:'https://img.alicdn.com/imgextra/i3/4161056916/O1CN016YQKKD20xZqiBeTGe_!!4161056916.png'
		// },

    // bgImg:{
    //   url:"https://img.alicdn.com/imgextra/i4/4161056916/O1CN01L2yTB320xZqeyvHdO_!!4161056916.png",
    //   width:551,
    //   height:69
    // },
    // progressImg:{
    //   url:"https://img.alicdn.com/imgextra/i2/4161056916/O1CN015FxPcD20xZqiWOV21_!!4161056916.png",
    //   width:551,
    //   height:59
		// },
		
		// tipImg:{
		// 	url:'https://img.alicdn.com/imgextra/i4/4161056916/O1CN01G8t3hj20xZqZN2XqK_!!4161056916.png'
		// },

		// tipBar:{
		// 	url:'https://img.alicdn.com/imgextra/i4/4161056916/O1CN014eia4g20xZqkzcQXh_!!4161056916.png'
		// },

		// cancelBtn:{
		// 	url:'https://img.alicdn.com/imgextra/i2/4161056916/O1CN01bhkmNX20xZqdE9is5_!!4161056916.png'
		// },

		// xMan:{
		// 	url:'https://img.alicdn.com/imgextra/i1/4161056916/O1CN01PzG1eD20xZqe97ATg_!!4161056916.png'
		// },

		// tagImg:[
		// 	{url:'https://img.alicdn.com/imgextra/i2/4161056916/O1CN01ZODAva20xZqnt39AV_!!4161056916.png'},
		// 	{url:'https://img.alicdn.com/imgextra/i2/4161056916/O1CN01DYtY6k20xZqj9mJWJ_!!4161056916.png'}
		// ],

		ap:0,
		showBtn:true
  },
  props: {
    mineData:""
  },
  onInit(){

		this.$page.pipei = this

		
		
		this.setData({
      ...getApp().pifu.pipeiGamePage,
			isVip:getApp().isVip
		})

		this.startDownTime()

    // this.setT = setInterval(() => {
    //   this.setData({
    //     step:this.data.step - this.props.length < 0 ? 0 : this.data.step - this.props.length,
    //     ap:this.data.ap + this.props.length >= 100 ? 100 : this.data.ap + this.props.length
    //   })

    //   if(this.data.step <= 0){
    //     clearInterval(this.setT)
    //   }
    // },150)
  },
  didMount() {
    this.animation = my.createAnimation();
    this.animation.translate('0%','150%').step();

    this.setData({
      animation: this.animation.export()
    })
  },
  didUpdate() {},
  didUnmount() {
    clearInterval(this.setT)
  },
  methods: {

		startDownTime(){
			clearInterval(this.setT)

			this.setData({
				ap:0,
				step:100
			})

			this.setT = setInterval(() => {
				this.setData({
					step:this.data.step - this.props.length < 0 ? 0 : this.data.step - this.props.length,
					ap:this.data.ap + this.props.length >= 100 ? 100 : this.data.ap + this.props.length
				})

				if(this.data.step <= 0){
					clearInterval(this.setT)
				}
			},150)
		},
    
		endPipei(){
			clearInterval(this.setT)

			this.setData({
				step:0,
				ap:100,
				showBtn:false
			})
		},

    enemyInit(o){

      console.info('组件内时间==',o)

      this.setData({
        enemyData:o
      })

    },

		//关闭
    closeList(){
      
      this.animation.translate('0%','-150%').step()
      this.setData({ animation: this.animation.export() })

      setTimeout(() => {
        this.$page.setData({
					showGame:'main',
					startGame:false,
					roomId:''
        })
      }, 400);
    },


    //取消匹配
    cancelPipei(){
      clearInterval(this.setT)
			getApp().cancelPiPei();
			getApp().getOut()
			this.$page.cancelSet()
      this.closeList();
    }
  },
});
